import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

// 开发环境不使用懒加载, 因为懒加载页面太多的话会造成webpack热更新太慢, 所以只有生产环境使用懒加载
const _import = require('./import-' + process.env.NODE_ENV)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'main',
      redirect: { name: 'music' },
      component: require('@/views/main').default,
      children: [
        {
          path: 'music',
          name: 'music',
          component: _import('music/index')
        },
        {
          path: 'playlist/detail',
          name: 'playlist-detail',
          component: _import('playlist/detail')
        },
      ]
    },
    {
      path: '*',
      redirect: '/'
    }
  ]
})
